import React, { useCallback,useMemo } from "react";
import { useDispatch,useSelector } from "react-redux";
import {Link,useHistory} from 'react-router-dom'
import '../../../../components/header/style.scss'
export default function DetailHeader() {
    const history=useHistory()
    const returnBack=()=>{
        history.goBack();
    }
    const orderData = useSelector((state) => state.getIn(["order", "data"]));

    const computed = useMemo(() => {
        let count = 0;
        orderData.forEach((item) => {
            count += item.get("count");
        });
        return  count ;
    }, [orderData]);
    return (
        <div className='detailHeader'>
            <span className='home iconfont icon-zuojiantou' onClick={returnBack}></span>
            <span className='title' >网易严选</span>
            <span className='search iconfont icon-sousuo'></span>
            <div className="cart"><Link className=' iconfont icon-icon-' to={{pathname:'/cart'}}></Link><span className='count'>{computed}</span></div>
            
        </div>
    )
}
